package cn.itxf.pethome.service.impl;

import cn.itxf.pethome.domain.Department;
import cn.itxf.pethome.mapper.DepartmentMapper;
import cn.itxf.pethome.query.DepartmentQuery;
import cn.itxf.pethome.service.IDepartmentService;
import cn.itxf.pethome.utils.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
@Service
public class DepartmentServiceImpl implements IDepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;

//    @Override
//    public List<Department> findAll(DepartmentQuery query) {
//        return departmentMapper.findAll(query);
//    }

    @Override
    public ResultBean<Department> queryAll(DepartmentQuery query) {
        ResultBean<Department> res = new ResultBean<>();
        res.setTotal(departmentMapper.findCounAll(query));
        res.setPageList(departmentMapper.findAll(query));
        return res;
    }

    @Override
    public Department finByid(Long id) {
        return departmentMapper.finByid(id);
    }

    @Transactional
    @Override
    public void insert(Department department) {
        departmentMapper.insert(department);
    }

    @Transactional
    @Override
    public void update(Department department) {
        departmentMapper.update(department);
    }

    @Transactional
    @Override
    public void detele(Long id) {
        departmentMapper.detele(id);
    }

   /* @Override
    public Long findCounAll(DepartmentQuery departmentQuery) {
        return departmentMapper.findCounAll(departmentQuery);
    }*/
}
